package com.imonsoft.sqm.dao.business.ipic_system;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.business.ipic_system.Incoming;
import com.imonsoft.sqm.pojo.business.ipic_system.IncomingExample;
import com.imonsoft.sqm.vo.business.ipic_system.IncomingVo;

import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
@SuppressWarnings("deprecation")
@Repository("incomingDAO")
public class IncomingDAOImpl extends SqlMapClientDaoSupport implements IncomingDAO {

    /**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public IncomingDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int countIncomingByExample(IncomingExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("tt_incoming.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int deleteIncomingByExample(IncomingExample example) {
		int rows = getSqlMapClientTemplate().delete("tt_incoming.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int deleteIncomingByPrimaryKey(Long id) {
		Incoming key = new Incoming();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete("tt_incoming.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public Long insertIncoming(Incoming record) {
		Object newKey = getSqlMapClientTemplate().insert("tt_incoming.ibatorgenerated_insert", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public Long insertIncomingSelective(Incoming record) {
		Object newKey = getSqlMapClientTemplate().insert("tt_incoming.ibatorgenerated_insertSelective", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<Incoming> selectIncomingByExample(IncomingExample example) {
		List<Incoming> list = getSqlMapClientTemplate().queryForList("tt_incoming.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public Incoming selectIncomingByPrimaryKey(Long id) {
		Incoming key = new Incoming();
		key.setId(id);
		Incoming record = (Incoming) getSqlMapClientTemplate().queryForObject("tt_incoming.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int updateIncomingByExampleSelective(Incoming record, IncomingExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("tt_incoming.ibatorgenerated_updateByExampleSelective", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int updateIncomingByExample(Incoming record, IncomingExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("tt_incoming.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int updateIncomingByPrimaryKeySelective(Incoming record) {
		int rows = getSqlMapClientTemplate().update("tt_incoming.ibatorgenerated_updateByPrimaryKeySelective", record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	public int updateIncomingByPrimaryKey(Incoming record) {
		int rows = getSqlMapClientTemplate().update("tt_incoming.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table tt_incoming
	 * @ibatorgenerated  Wed Jun 05 18:59:28 CST 2013
	 */
	private static class UpdateByExampleParms extends IncomingExample {
		private Object record;

		public UpdateByExampleParms(Object record, IncomingExample example) {
			super(example);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<IncomingVo> getDataGridVoBy(Incoming incoming, Pager pager) {
		
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("tt_incoming.ibatorgenerated_countByIncoming", incoming);
		List<IncomingVo> rows = getSqlMapClientTemplate().queryForList("tt_incoming.ibatorgenerated_selectByIncoming", incoming, pager.getSkipResults(), pager.getRows());
		DataGrid<IncomingVo> dataGrid = new DataGrid<IncomingVo>(count, rows);
		return dataGrid;
	}
}